<?php return['rich_mem_enterpr'=>'
CREATE TABLE %table_prefix%rich_mem_enterpr(
site_owner_id INT UNSIGNED NOT NULL DEFAULT "123456789",
rich_mem_group_name VARCHAR(30) NOT NULL,
id INT UNSIGNED NOT NULL,/*会员ID*/
name VARCHAR(20) NOT NULL,
email VARCHAR(80) UNIQUE,
password VARCHAR(100) NOT NULL,
signature VARCHAR(300),
create_datetime TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
last_login_datetime DATETIME,
score INT UNSIGNED NOT NULL DEFAULT 0,
UNIQUE(site_owner_id, id, name),
FOREIGN KEY(rich_mem_group_name)
  REFERENCES %table_prefix%rich_mem_group(name)
  ON UPDATE CASCADE
  ON DELETE RESTRICT
)ENGINE InnoDB CHARACTER SET utf8;','enterpr_article_category'=>'
CREATE TABLE %table_prefix%enterpr_article_category (
id INT UNSIGNED NOT NULL AUTO_INCREMENT,
parent_id SMALLINT(4) UNSIGNED,
name VARCHAR(30) NOT NULL,
expand BOOLEAN DEFAULT TRUE,
create_datetime TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
sort_index SMALLINT(4) UNSIGNED DEFAULT 0,
level ENUM("0", "1") NOT NULL,
site_owner_id INT UNSIGNED NOT NULL DEFAULT "123456789",
PRIMARY KEY(id),
UNIQUE(name,parent_id)
) ENGINE InnoDB CHARACTER SET utf8;
','enterpr_article'=>"\r\nCREATE TABLE %table_prefix%enterpr_article (\r\nid INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,\r\ntitle VARCHAR(50) NOT NULL,\r\nthumbnail VARCHAR(255),\r\ncontent TEXT,\r\ncreate_datetime DATETIME NOT NULL,\r\nrelease_datetime DATETIME,\r\nmodify_datetime TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,\r\nauthor VARCHAR(30),\r\nkeywords VARCHAR(3200),\r\nsummary VARCHAR(600),\r\ncategory_id INT UNSIGNED,\r\nstatus ENUM('unreleased','released') NOT NULL,\r\nviews INT(8) UNSIGNED DEFAULT 0,\r\ntopmost BOOLEAN DEFAULT FALSE,\r\ncomment_count MEDIUMINT UNSIGNED DEFAULT 0,\r\nsite_owner_id INT UNSIGNED NOT NULL DEFAULT \"123456789\",\r\ncollect_count MEDIUMINT UNSIGNED DEFAULT 0\r\n) ENGINE InnoDB CHARACTER SET utf8;\r\n",'freight_template'=>'CREATE TABLE %table_prefix%freight_template (
id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
site_owner_id INT UNSIGNED NOT NULL DEFAULT "123456789",
name VARCHAR(25) NOT NULL,
product_addr VARCHAR(50) NOT NULL,
delivery_hours SMALLINT(3) UNSIGNED NOT NULL,
bear_freight ENUM("seller", "buyer") NOT NULL,
valuation_type ENUM("number", "weight", "volume") NOT NULL,
json_express TEXT,
json_ems TEXT,
json_post TEXT,
json_free_condition TEXT,
delivery_type SET("express", "ems", "post")
)ENGINE InnoDB CHARACTER SET utf8;','enterpr_product_category'=>'
CREATE TABLE %table_prefix%enterpr_product_category (
id INT UNSIGNED NOT NULL AUTO_INCREMENT,
parent_id SMALLINT UNSIGNED,
name VARCHAR(30) NOT NULL,
expand BOOLEAN NOT NULL DEFAULT TRUE,
create_datetime TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
sort_index SMALLINT UNSIGNED NOT NULL DEFAULT 0,
level ENUM("0", "1") NOT NULL,
site_owner_id INT UNSIGNED NOT NULL DEFAULT "123456789",
PRIMARY KEY(id),
UNIQUE(name,parent_id)
) ENGINE InnoDB CHARACTER SET utf8;
','enterpr_product'=>"\r\nCREATE TABLE %table_prefix%enterpr_product (\r\nid INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,\r\ncategory_id SMALLINT UNSIGNED,\r\nsell_point VARCHAR(450),\r\nfreight_template_id INT UNSIGNED,\r\nouter_id VARCHAR(20),\r\ntitle VARCHAR(90) NOT NULL,\r\ncost_price FLOAT(10, 2) NOT NULL,\r\ndiscount_price FLOAT(10, 2),\r\ndescription VARCHAR(400),\r\nkeywords VARCHAR(400),\r\ndetail TEXT,\r\nm_detail TEXT,\r\nquantity SMALLINT(5) UNSIGNED DEFAULT 0,\r\ncollect_count MEDIUMINT UNSIGNED DEFAULT 0,\r\nsold_count MEDIUMINT UNSIGNED DEFAULT 0,\r\n-- comment_count MEDIUMINT UNSIGNED DEFAULT 0,\r\nmain_pic_uri VARCHAR(255) NOT NULL,\r\nsub_pic_uris VARCHAR(1100),\r\nbrand VARCHAR(50),\r\nstatus ENUM('never_up','activity_finished','timming_shelf','off_shelf','sold_in','in_promotion') NOT NULL,\r\ncreate_datetime TIMESTAMP DEFAULT CURRENT_TIMESTAMP,\r\nrelease_datetime DATETIME,\r\ndown_datetime DATETIME,\r\nactivity_begin_datetime DATETIME,\r\nactivity_end_datetime DATETIME,\r\nviews INT(8) DEFAULT 0,\r\nsite_owner_id INT UNSIGNED NOT NULL DEFAULT \"123456789\",\r\nguide_link1 VARCHAR(285),\r\nguide_link2 VARCHAR(285),\r\naddr VARCHAR(40),\r\nINDEX(title)\r\n) ENGINE InnoDB CHARACTER SET utf8;\r\n",'enterpr_guestbook'=>'
CREATE TABLE %table_prefix%enterpr_guestbook (
id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
client_ip VARCHAR(50),
content VARCHAR(1000) NOT NULL,
email VARCHAR(80),
tel VARCHAR(80),
site_owner_id INT UNSIGNED NOT NULL DEFAULT "123456789",
status ENUM("unread", "readed", "replied") NOT NULL,
create_datetime TIMESTAMP DEFAULT CURRENT_TIMESTAMP
) ENGINE InnoDB CHARACTER SET utf8;
','enterpr_guestbook_reply'=>'
CREATE TABLE %table_prefix%enterpr_guestbook_reply (
id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
guestbook_id INT UNSIGNED NOT NULL UNIQUE,
site_owner_id INT UNSIGNED NOT NULL DEFAULT "123456789",
content VARCHAR(1000) NOT NULL,
reply_datetime TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY(guestbook_id)
	REFERENCES %table_prefix%enterpr_guestbook(id)
	ON DELETE CASCADE
	ON UPDATE CASCADE
) ENGINE InnoDB CHARACTER SET utf8;
','shopping_cart'=>'
CREATE TABLE %table_prefix%shopping_cart(
site_owner_id INT UNSIGNED NOT NULL DEFAULT "123456789",
member_id INT UNSIGNED NOT NULL,
detail_json TEXT,
PRIMARY KEY(member_id),
FOREIGN KEY(site_owner_id,member_id)
  REFERENCES %table_prefix%rich_mem_enterpr(site_owner_id,id)
  ON DELETE CASCADE
  ON UPDATE CASCADE
)ENGINE InnoDB CHARACTER SET utf8;','order'=>'
CREATE TABLE %table_prefix%order (
id CHAR(10) NOT NULL PRIMARY KEY,
site_owner_id INT UNSIGNED NOT NULL DEFAULT "123456789",
member_id INT UNSIGNED NOT NULL,
total_amount FLOAT(9, 2),/*总金额*/
actual_amount FLOAT(9, 2),/*实付金额*/
detail_json TEXT,
payment_type ENUM("alipay","weixin"),
display BOOLEAN DEFAULT TRUE, /*用于订单假删除，控制订单显示状态*/
status ENUM(
	"WAIT_BUYER_PAY",/*等待支付*/
	"TRADE_FINISHED",/*支付成功，且程序自动处理内容也成功，但订单还需要客服手动处理*/
	"TRADE_SUCCESS",/*支付成功，且订单处理成功*/
	"TRADE_PENDING",/*支付成功,但官网处理订单失败*/
	"TRADE_CLOSED"/*订单关闭,即不可再进行任何操作(比如售后，或者未支付订单，7天后自动关闭)*/
) NOT NULL,
comment VARCHAR(1500),
create_datetime DATETIME NOT NULL,
modify_datetime TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
finished_datetime DATETIME,
FOREIGN KEY(site_owner_id,member_id)
  REFERENCES %table_prefix%rich_mem_enterpr(site_owner_id,id)
  ON DELETE CASCADE
  ON UPDATE CASCADE
)ENGINE InnoDB CHARACTER SET utf8;','sale_records'=>'CREATE TABLE %table_prefix%sale_records(
id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
site_owner_id INT UNSIGNED NOT NULL DEFAULT "123456789",
member_id INT UNSIGNED NOT NULL,
order_id CHAR(10),
build_datetime TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
content VARCHAR(3000) NOT NULL,
has_error BOOLEAN DEFAULT FALSE,-- 该交易是否包含错误
total_price FLOAT(9, 2) NOT NULL,
actual_price FLOAT(9, 2) NOT NULL,
FOREIGN KEY(site_owner_id,member_id)
  REFERENCES %table_prefix%rich_mem_enterpr(site_owner_id,id)
  ON DELETE CASCADE
  ON UPDATE CASCADE
) ENGINE InnoDB CHARACTER SET utf8;','collect'=>'CREATE TABLE %table_prefix%collect (
id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
site_owner_id INT UNSIGNED NOT NULL DEFAULT "123456789",
member_id INT UNSIGNED NOT NULL,
type ENUM("product", "article") NOT NULL,
assoc_id INT UNSIGNED NOT NULL, /*关联到的产品或文章ID*/
create_datetime TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
UNIQUE(type,assoc_id,member_id,site_owner_id),
FOREIGN KEY(site_owner_id,member_id)
  REFERENCES %table_prefix%rich_mem_enterpr(site_owner_id,id)
  ON DELETE CASCADE
  ON UPDATE CASCADE
)ENGINE InnoDB CHARACTER SET utf8;',"addr_receiver"=>'CREATE TABLE %table_prefix%addr_receiver (
id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
site_owner_id INT UNSIGNED NOT NULL DEFAULT "123456789",
member_id INT UNSIGNED NOT NULL,
contact VARCHAR(20) NOT NULL,
addr VARCHAR(40) NOT NULL,
street VARCHAR(120) NOT NULL,
postcode CHAR(6) NOT NULL,/*中国邮编统一为6位，故暂定为6*/
tel VARCHAR(20),
mobile VARCHAR(15),
FOREIGN KEY(site_owner_id,member_id)
  REFERENCES %table_prefix%rich_mem_enterpr(site_owner_id,id)
  ON DELETE CASCADE
  ON UPDATE CASCADE
)ENGINE InnoDB CHARACTER SET utf8;',];?>